﻿using System;
using System.Data;

namespace KamLib
{
    public class SessionCommand : IDbCommand
    {
        public SessionConnection Connection { get; set; }
        IDbConnection IDbCommand.Connection
        {
            get { return Connection; } 
            set { Connection = (SessionConnection)value; }
        }
        public string CommandText { get; set; }
        public int CommandTimeout { get; set; }
        public CommandType CommandType { get { return CommandType.Text; }
            set { throw new NotImplementedException("SessionCommand.CommandType"); }
        }

        public IDbTransaction Transaction { get; set; }

        public SessionCommand(SessionConnection connection) { Connection = connection; }

        public void Dispose() { }
        public void Prepare() { }
        public void Cancel() { }
        public IDbDataParameter CreateParameter() { throw new NotImplementedException("SessionCommand.CreateParameter"); }

        public int ExecuteNonQuery() { return Connection.Session.ExecuteNonQuery(CommandText); }

        public IDataReader ExecuteReader()
        {
            return new SessionDataReader(Connection.Session.ExecuteQuery(CommandText));
        }
        public IDataReader ExecuteReader(CommandBehavior behavior) { return ExecuteReader(); }
        public object ExecuteScalar() { return Connection.Session.ExecuteScalar(CommandText); }


        public IDataParameterCollection Parameters { get { throw new NotImplementedException(); } }

        public UpdateRowSource UpdatedRowSource
        {
            get { throw new NotImplementedException("SessionCommand.UpdatedRowSource"); }
            set { throw new NotImplementedException("SessionCommand.UpdatedRowSource"); }
        }
    }

}
